﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;

namespace Campus {
    class CampusShuttle : Unit {
        static public List<Texture2D> IdleAnim = new List<Texture2D>();
        static public List<Texture2D> WalkRightAnim = new List<Texture2D>();
        static public List<Texture2D> WalkLeftAnim = new List<Texture2D>();
        static public List<Texture2D> WalkUpAnim = new List<Texture2D>();
        static public List<Texture2D> WalkDownAnim = new List<Texture2D>();
        static public List<Texture2D> DieAnim = new List<Texture2D>();

        private void CreateAbilites() {
            Abilities.Add("Move", new MoveAbility(this, Vector2.Zero));
            Abilities.Add("Garrison", new GarrisonAbility(MenuIcons.GarrisonIcon, this, 100, delegate(Unit u) {return true;}));
            Abilities.Add("Expell Units", new ExpellUnitsAbility(MenuIcons.ExpellIcon, this));
        }

        public CampusShuttle(Vector2 position, Player player, Level level) 
            : base(CreateDictionary(), position, 200, player, level, new Dictionary<String, Ability>(), 
            new Dictionary<string,AbilitySubMenu>())
        {
            m_name = "Campus Shuttle";
            this.MoveSpeed = 150.0f;
            CanAttack = false;
            m_entitySelectedImage = IdleAnim[0];
            Size = new Vector2(100, 100);
            CreateAbilites();
        }

        public override void Update(GameTime gameTime, bool checkInput, bool updateBoundingBox)
        {
            base.Update(gameTime, checkInput, updateBoundingBox);
        }
        static private Dictionary<Unit.UnitState, Animation> CreateDictionary()
        {
            Dictionary<Unit.UnitState, Animation> dict = new Dictionary<UnitState, Animation>();

            // Creates an animation based on the certain static list, then adds it to the
            // Dictionary under the appropriate state.
            Random rgen = new Random();

            dict.Add(UnitState.Idle, new Animation(IdleAnim, rgen.Next(30, 60), true));
            dict.Add(UnitState.WalkRight, new Animation(WalkRightAnim, 75, true));
            dict.Add(UnitState.WalkLeft, new Animation(WalkLeftAnim, 75, true));
            dict.Add(UnitState.WalkDown, new Animation(WalkDownAnim, 200, true));
            dict.Add(UnitState.WalkUp, new Animation(WalkUpAnim, 50, true));
            //dict.Add(UnitState.AttackRight, new Animation(AttackRightAnim, 150, true));
            //dict.Add(UnitState.AttackLeft, new Animation(AttackLeftAnim, 150, true));
            dict.Add(UnitState.Die, new Animation(DieAnim, 150, false));

            return dict;
        }
        

        static public void InitializeAnimations(ContentManager Content)
        {
            // Loads all the idle animation frames
            IdleAnim.Add(Content.Load<Texture2D>("Units/Shuttle/shuttleIDLE_0"));
            IdleAnim.Add(Content.Load<Texture2D>("Units/Shuttle/shuttleIDLE_1"));
            IdleAnim.Add(Content.Load<Texture2D>("Units/Shuttle/shuttleIDLE_2"));
            IdleAnim.Add(Content.Load<Texture2D>("Units/Shuttle/shuttleIDLE_3"));

            // Loads all the walk left frames
            WalkLeftAnim.Add(Content.Load<Texture2D>("Units/Shuttle/shuttleWALKLEFT_0"));
            WalkLeftAnim.Add(Content.Load<Texture2D>("Units/Shuttle/shuttleWALKLEFT_1"));
            WalkLeftAnim.Add(Content.Load<Texture2D>("Units/Shuttle/shuttleWALKLEFT_2"));
            WalkLeftAnim.Add(Content.Load<Texture2D>("Units/Shuttle/shuttleWALKLEFT_3"));
            WalkLeftAnim.Add(Content.Load<Texture2D>("Units/Shuttle/shuttleWALKLEFT_4"));
            WalkLeftAnim.Add(Content.Load<Texture2D>("Units/Shuttle/shuttleWALKLEFT_5"));

            // Loads all the walk right frames
            WalkRightAnim.Add(Content.Load<Texture2D>("Units/Shuttle/shuttleWALKRIGHT_5"));
            WalkRightAnim.Add(Content.Load<Texture2D>("Units/Shuttle/shuttleWALKRIGHT_4"));
            WalkRightAnim.Add(Content.Load<Texture2D>("Units/Shuttle/shuttleWALKRIGHT_3"));
            WalkRightAnim.Add(Content.Load<Texture2D>("Units/Shuttle/shuttleWALKRIGHT_2"));
            WalkRightAnim.Add(Content.Load<Texture2D>("Units/Shuttle/shuttleWALKRIGHT_1"));
            WalkRightAnim.Add(Content.Load<Texture2D>("Units/Shuttle/shuttleWALKRIGHT_0"));

            // Loads all the walk up frames
            WalkUpAnim.Add(Content.Load<Texture2D>("Units/Shuttle/shuttleWALKUP_0"));
            WalkUpAnim.Add(Content.Load<Texture2D>("Units/Shuttle/shuttleWALKUP_1"));

            // Loads all the walk down frames
            WalkDownAnim.Add(Content.Load<Texture2D>("Units/Shuttle/shuttleWALKDOWN_0"));
            WalkDownAnim.Add(Content.Load<Texture2D>("Units/Shuttle/shuttleWALKDOWN_1"));
            WalkDownAnim.Add(Content.Load<Texture2D>("Units/Shuttle/shuttleWALKDOWN_2"));

            DieAnim.Add(Content.Load<Texture2D>("Units/Shuttle/shuttleDEATH_0"));
            DieAnim.Add(Content.Load<Texture2D>("Units/Shuttle/shuttleDEATH_1"));
            DieAnim.Add(Content.Load<Texture2D>("Units/Shuttle/shuttleDEATH_2"));
            DieAnim.Add(Content.Load<Texture2D>("Units/Shuttle/shuttleDEATH_3"));
            DieAnim.Add(Content.Load<Texture2D>("Units/Shuttle/shuttleDEATH_4"));
            DieAnim.Add(Content.Load<Texture2D>("Units/Shuttle/shuttleDEATH_5"));
            DieAnim.Add(Content.Load<Texture2D>("Units/Shuttle/shuttleDEATH_6"));
        }
    }
}
